<?php

class Crud_Form_Decorator_Refresh extends Zend_Form_Decorator_Abstract
{
    /**
     * Decorate content and/or element
     *
     * @param  string $content
     * @return string
     * @throws Zend_Form_Decorator_Exception when unimplemented
     */
	public function render($content)
	{
		$element = $this->getElement();
		$name = $element->getName();
		
		$request = Zend_Controller_Front::getInstance()->getRequest();
		$table = $request->getParam('table');
		$id = $request->getParam('id');
		
		$url = "/admin/crud/form/table/$table/id/$id/column/$name";
		$editUrl = $this->getOption('url');
		$content = "<div id='column_$name'>
		<br /><br /><a id='refresh_$name' url='$url' class='crud_refresh' onclick='elementRefresh(this);'>Обновить</a>
		<a href='$editUrl' target='_blank'>Редактировать</a>
		
		$content
		
		</div>";
		
		return $content;
	
	}
	
}